package wangy.pvp.entrance;

import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;

import wangy.pvp.ruler.Ruler;
import wangy.pvp.scanner.Scanner;

public abstract class Entrance {

	protected Scanner scanner;
	protected Ruler ruler;

	public void start(String address){
		
		this.Initialize(address);
		
		PipedOutputStream out= new PipedOutputStream();
		try {
			PipedInputStream in =  new PipedInputStream(out);

			scanner.setOut(out);
			ruler.setInput(in);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		scanner.selectFiles();
		scanner.startAllScanner();
		new Thread((Runnable)scanner).run();
		new Thread((Runnable)ruler).run();
	}

	public abstract void Initialize(String address);

	public static void main(String args[]){
		new JavaClassEntrance().start("test");
	}
}
